package com.pos.clothes.service.serviceImpl;

import com.pos.clothes.mapper.CancelMapper;
import com.pos.clothes.pojo.Order_detail;
import com.pos.clothes.pojo.Cancel;
import com.pos.clothes.service.CancelService;
import com.pos.clothes.service.OrderService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
//import sun.security.x509.SerialNumber;

import java.util.Date;
import java.util.List;
import java.util.Random;
@Service
public class CancelServiceImpl implements CancelService {

    @Autowired
    CancelMapper mapper;
    @Override
    public Integer insertCancel(Integer userid, Integer idorder, Integer normid, Integer number, Float total, String note) {
        Integer serialNumber = new Random().nextInt(10000)+1;
        Cancel cancel = new Cancel(userid,idorder,normid,serialNumber,number*-1,total,new Date(System.currentTimeMillis()),note);
        if(mapper.insertCancel(cancel)>0){
            return 1;
        }else {
            return -1;
        }
    }

    @Override
    public List<Cancel> getReturnNorm(Integer orderid) {
        return mapper.getAllCancel(orderid);
    }
}
